﻿@model MSAcademic.v2.Web.Areas.Admin.Models.Article.ArticleIndexModel

@{
    ViewBag.Title = "Pregled novosti";
}

<script type="text/javascript"> 
    $(function () {
        $('.actions-wrapper .create').on('mousedown', function () {
            msacademic.dialogPopup( $(this).data('url'));
        });
    });
</script>

<h2>Pregled tekstova na portalu</h2>

<div id="ArticlesList">

    <!-- Izlist članaka -->
    <ul class="list-wrapper">
        @foreach (var a in Model.Articles)
        {
            <li class="@(a.Item1.IsHidden || !a.Item1.PublishedOn.HasValue ? "hidden" : "")">
                <a href="@Url.RouteUrl("ArticleUpdateAdmin", new { id = a.Item1.Id })" class="item clearfix">
                    <div class="picture"> <img src="@a.Item1.PictureUrlThumbnail" alt="@a.Item1.Title" /> </div>

                    <div class="data">
                        <div class="title">@a.Item1.Title</div>
                        <div class="meta"> <span class="author">@a.Item2.FirstName @a.Item2.LastName</span> 
                            - @(a.Item1.PublishedOn.HasValue ? "Objavljeno: " + @a.Item1.PublishedOn.Value.ToString("dd. MMMM yyyy. u H:m") : "Članak nije objavljen") 
                            - @(a.Item1.IsHidden ? "Članak je skriven od očiju javnosti" : "Članak je vidljiv na webu") 
                        </div>

                        <div class="text">
                            Kratki tekst: <b>@a.Item1.ShortText.ToString().Length</b> znakova / 
                            Dugi tekst: <b>@a.Item1.LongText.ToString().Length</b> znakova
                        </div>
                    </div>

                </a>

                <div class="actions-wrapper">
                    @if (a.Item1.PublishedOn.HasValue)
                    {
                        <a>Objavljeno @a.Item1.PublishedOn.Value.ToString("dd. MMMM yyyy. u H:m")</a>
                    }
                    else if (Model.CanPublishAndHide)
                    {
                        <a href="@Url.RouteUrl("ArticlePublishAdmin", new { id = a.Item1.Id, page = Model.Page })" class="positive">Objavi <i class=" icon-bolt"></i></a>
                    }
                    <a href="@Url.RouteUrl("ArticleUpdateAdmin", new { id = a.Item1.Id })">Uredi <i class="icon-pencil"></i></a>
                    @if(Model.CanPublishAndHide)
                    {
                        <a href="@Url.RouteUrl("ArticleToggleHiddenAdmin", new { id = a.Item1.Id, page = Model.Page })" class="special">@(a.Item1.IsHidden ? "Pokazi" : "Sakrij")</a>
                    }
                </div>
            </li>
        }
    </ul>

    <!-- Akcije i paginacija -->

    <div class="actions-wrapper"> <a data-url="@Url.RouteUrl("ArticleCreateAdmin")" class="positive create">Budi zakon, stvori članak <i class="icon-edit"></i> </a> </div>
    <div class="pagination-wrapper">
        <ul>
            @if (Model.Page > 1)
            {
                <li class="ui-element-navi"><a href="@Url.RouteUrl("ArticleIndexAdmin", new { page = Model.Page - 1 })"> <i class="icon-chevron-left"></i>  Prethodna stranica </a></li>
            }

            @for (int i = 1; i <= Model.NumberOfPages; i++)
            {
                <li class="@(i == Model.Page ? "ui-state-selected" : "")">
                    @if (i == Model.Page)
                    {
                        <a>@i</a>
                    }
                    else
                    {
                        <a href="@Url.RouteUrl("ArticleIndexAdmin", new { page = i })">@i</a>
                    }
                </li>
            }

            @if (Model.Page < Model.NumberOfPages)
            {
                <li class="ui-element-navi"><a href="@Url.RouteUrl("ArticleIndexAdmin", new { page = Model.Page + 1 })">Sljedeća stranica <i class="icon-chevron-right"></i> </a></li>
            }
        </ul>
    </div>

</div>
